{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c3bf762a",
   "metadata": {},
   "source": [
    "* 本学习记录人：林文轩\n",
    "* 学习实践：2021-11-10\n",
    "* week05\n",
    "# 本周学习内容\n",
    "## 1. 啤酒歌谣项目详解\n",
    "## 2. 用户输入\n",
    "## 3. while循环\n",
    "## 4. 列表的引入\n",
    "# 1.啤酒歌谣项目详解（P43自己写，P44课本解读)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e2363e4e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "99 青岛s 在啤酒柜中\n",
      "99 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "98 青岛s 在啤酒柜中\n",
      "\n",
      "98 青岛s 在啤酒柜中\n",
      "98 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "97 青岛s 在啤酒柜中\n",
      "\n",
      "97 青岛s 在啤酒柜中\n",
      "97 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "96 青岛s 在啤酒柜中\n",
      "\n",
      "96 青岛s 在啤酒柜中\n",
      "96 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "95 青岛s 在啤酒柜中\n",
      "\n",
      "95 青岛s 在啤酒柜中\n",
      "95 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "94 青岛s 在啤酒柜中\n",
      "\n",
      "94 青岛s 在啤酒柜中\n",
      "94 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "93 青岛s 在啤酒柜中\n",
      "\n",
      "93 青岛s 在啤酒柜中\n",
      "93 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "92 青岛s 在啤酒柜中\n",
      "\n",
      "92 青岛s 在啤酒柜中\n",
      "92 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "91 青岛s 在啤酒柜中\n",
      "\n",
      "91 青岛s 在啤酒柜中\n",
      "91 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "90 青岛s 在啤酒柜中\n",
      "\n",
      "90 青岛s 在啤酒柜中\n",
      "90 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "89 青岛s 在啤酒柜中\n",
      "\n",
      "89 青岛s 在啤酒柜中\n",
      "89 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "88 青岛s 在啤酒柜中\n",
      "\n",
      "88 青岛s 在啤酒柜中\n",
      "88 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "87 青岛s 在啤酒柜中\n",
      "\n",
      "87 青岛s 在啤酒柜中\n",
      "87 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "86 青岛s 在啤酒柜中\n",
      "\n",
      "86 青岛s 在啤酒柜中\n",
      "86 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "85 青岛s 在啤酒柜中\n",
      "\n",
      "85 青岛s 在啤酒柜中\n",
      "85 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "84 青岛s 在啤酒柜中\n",
      "\n",
      "84 青岛s 在啤酒柜中\n",
      "84 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "83 青岛s 在啤酒柜中\n",
      "\n",
      "83 青岛s 在啤酒柜中\n",
      "83 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "82 青岛s 在啤酒柜中\n",
      "\n",
      "82 青岛s 在啤酒柜中\n",
      "82 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "81 青岛s 在啤酒柜中\n",
      "\n",
      "81 青岛s 在啤酒柜中\n",
      "81 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "80 青岛s 在啤酒柜中\n",
      "\n",
      "80 青岛s 在啤酒柜中\n",
      "80 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "79 青岛s 在啤酒柜中\n",
      "\n",
      "79 青岛s 在啤酒柜中\n",
      "79 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "78 青岛s 在啤酒柜中\n",
      "\n",
      "78 青岛s 在啤酒柜中\n",
      "78 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "77 青岛s 在啤酒柜中\n",
      "\n",
      "77 青岛s 在啤酒柜中\n",
      "77 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "76 青岛s 在啤酒柜中\n",
      "\n",
      "76 青岛s 在啤酒柜中\n",
      "76 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "75 青岛s 在啤酒柜中\n",
      "\n",
      "75 青岛s 在啤酒柜中\n",
      "75 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "74 青岛s 在啤酒柜中\n",
      "\n",
      "74 青岛s 在啤酒柜中\n",
      "74 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "73 青岛s 在啤酒柜中\n",
      "\n",
      "73 青岛s 在啤酒柜中\n",
      "73 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "72 青岛s 在啤酒柜中\n",
      "\n",
      "72 青岛s 在啤酒柜中\n",
      "72 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "71 青岛s 在啤酒柜中\n",
      "\n",
      "71 青岛s 在啤酒柜中\n",
      "71 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "70 青岛s 在啤酒柜中\n",
      "\n",
      "70 青岛s 在啤酒柜中\n",
      "70 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "69 青岛s 在啤酒柜中\n",
      "\n",
      "69 青岛s 在啤酒柜中\n",
      "69 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "68 青岛s 在啤酒柜中\n",
      "\n",
      "68 青岛s 在啤酒柜中\n",
      "68 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "67 青岛s 在啤酒柜中\n",
      "\n",
      "67 青岛s 在啤酒柜中\n",
      "67 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "66 青岛s 在啤酒柜中\n",
      "\n",
      "66 青岛s 在啤酒柜中\n",
      "66 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "65 青岛s 在啤酒柜中\n",
      "\n",
      "65 青岛s 在啤酒柜中\n",
      "65 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "64 青岛s 在啤酒柜中\n",
      "\n",
      "64 青岛s 在啤酒柜中\n",
      "64 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "63 青岛s 在啤酒柜中\n",
      "\n",
      "63 青岛s 在啤酒柜中\n",
      "63 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "62 青岛s 在啤酒柜中\n",
      "\n",
      "62 青岛s 在啤酒柜中\n",
      "62 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "61 青岛s 在啤酒柜中\n",
      "\n",
      "61 青岛s 在啤酒柜中\n",
      "61 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "60 青岛s 在啤酒柜中\n",
      "\n",
      "60 青岛s 在啤酒柜中\n",
      "60 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "59 青岛s 在啤酒柜中\n",
      "\n",
      "59 青岛s 在啤酒柜中\n",
      "59 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "58 青岛s 在啤酒柜中\n",
      "\n",
      "58 青岛s 在啤酒柜中\n",
      "58 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "57 青岛s 在啤酒柜中\n",
      "\n",
      "57 青岛s 在啤酒柜中\n",
      "57 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "56 青岛s 在啤酒柜中\n",
      "\n",
      "56 青岛s 在啤酒柜中\n",
      "56 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "55 青岛s 在啤酒柜中\n",
      "\n",
      "55 青岛s 在啤酒柜中\n",
      "55 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "54 青岛s 在啤酒柜中\n",
      "\n",
      "54 青岛s 在啤酒柜中\n",
      "54 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "53 青岛s 在啤酒柜中\n",
      "\n",
      "53 青岛s 在啤酒柜中\n",
      "53 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "52 青岛s 在啤酒柜中\n",
      "\n",
      "52 青岛s 在啤酒柜中\n",
      "52 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "51 青岛s 在啤酒柜中\n",
      "\n",
      "51 青岛s 在啤酒柜中\n",
      "51 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "50 青岛s 在啤酒柜中\n",
      "\n",
      "50 青岛s 在啤酒柜中\n",
      "50 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "49 青岛s 在啤酒柜中\n",
      "\n",
      "49 青岛s 在啤酒柜中\n",
      "49 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "48 青岛s 在啤酒柜中\n",
      "\n",
      "48 青岛s 在啤酒柜中\n",
      "48 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "47 青岛s 在啤酒柜中\n",
      "\n",
      "47 青岛s 在啤酒柜中\n",
      "47 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "46 青岛s 在啤酒柜中\n",
      "\n",
      "46 青岛s 在啤酒柜中\n",
      "46 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "45 青岛s 在啤酒柜中\n",
      "\n",
      "45 青岛s 在啤酒柜中\n",
      "45 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "44 青岛s 在啤酒柜中\n",
      "\n",
      "44 青岛s 在啤酒柜中\n",
      "44 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "43 青岛s 在啤酒柜中\n",
      "\n",
      "43 青岛s 在啤酒柜中\n",
      "43 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "42 青岛s 在啤酒柜中\n",
      "\n",
      "42 青岛s 在啤酒柜中\n",
      "42 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "41 青岛s 在啤酒柜中\n",
      "\n",
      "41 青岛s 在啤酒柜中\n",
      "41 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "40 青岛s 在啤酒柜中\n",
      "\n",
      "40 青岛s 在啤酒柜中\n",
      "40 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "39 青岛s 在啤酒柜中\n",
      "\n",
      "39 青岛s 在啤酒柜中\n",
      "39 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "38 青岛s 在啤酒柜中\n",
      "\n",
      "38 青岛s 在啤酒柜中\n",
      "38 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "37 青岛s 在啤酒柜中\n",
      "\n",
      "37 青岛s 在啤酒柜中\n",
      "37 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "36 青岛s 在啤酒柜中\n",
      "\n",
      "36 青岛s 在啤酒柜中\n",
      "36 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "35 青岛s 在啤酒柜中\n",
      "\n",
      "35 青岛s 在啤酒柜中\n",
      "35 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "34 青岛s 在啤酒柜中\n",
      "\n",
      "34 青岛s 在啤酒柜中\n",
      "34 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "33 青岛s 在啤酒柜中\n",
      "\n",
      "33 青岛s 在啤酒柜中\n",
      "33 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "32 青岛s 在啤酒柜中\n",
      "\n",
      "32 青岛s 在啤酒柜中\n",
      "32 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "31 青岛s 在啤酒柜中\n",
      "\n",
      "31 青岛s 在啤酒柜中\n",
      "31 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "30 青岛s 在啤酒柜中\n",
      "\n",
      "30 青岛s 在啤酒柜中\n",
      "30 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "29 青岛s 在啤酒柜中\n",
      "\n",
      "29 青岛s 在啤酒柜中\n",
      "29 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "28 青岛s 在啤酒柜中\n",
      "\n",
      "28 青岛s 在啤酒柜中\n",
      "28 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "27 青岛s 在啤酒柜中\n",
      "\n",
      "27 青岛s 在啤酒柜中\n",
      "27 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "26 青岛s 在啤酒柜中\n",
      "\n",
      "26 青岛s 在啤酒柜中\n",
      "26 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "25 青岛s 在啤酒柜中\n",
      "\n",
      "25 青岛s 在啤酒柜中\n",
      "25 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "24 青岛s 在啤酒柜中\n",
      "\n",
      "24 青岛s 在啤酒柜中\n",
      "24 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "23 青岛s 在啤酒柜中\n",
      "\n",
      "23 青岛s 在啤酒柜中\n",
      "23 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "22 青岛s 在啤酒柜中\n",
      "\n",
      "22 青岛s 在啤酒柜中\n",
      "22 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "21 青岛s 在啤酒柜中\n",
      "\n",
      "21 青岛s 在啤酒柜中\n",
      "21 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "20 青岛s 在啤酒柜中\n",
      "\n",
      "20 青岛s 在啤酒柜中\n",
      "20 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "19 青岛s 在啤酒柜中\n",
      "\n",
      "19 青岛s 在啤酒柜中\n",
      "19 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "18 青岛s 在啤酒柜中\n",
      "\n",
      "18 青岛s 在啤酒柜中\n",
      "18 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "17 青岛s 在啤酒柜中\n",
      "\n",
      "17 青岛s 在啤酒柜中\n",
      "17 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "16 青岛s 在啤酒柜中\n",
      "\n",
      "16 青岛s 在啤酒柜中\n",
      "16 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "15 青岛s 在啤酒柜中\n",
      "\n",
      "15 青岛s 在啤酒柜中\n",
      "15 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "14 青岛s 在啤酒柜中\n",
      "\n",
      "14 青岛s 在啤酒柜中\n",
      "14 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "13 青岛s 在啤酒柜中\n",
      "\n",
      "13 青岛s 在啤酒柜中\n",
      "13 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "12 青岛s 在啤酒柜中\n",
      "\n",
      "12 青岛s 在啤酒柜中\n",
      "12 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "11 青岛s 在啤酒柜中\n",
      "\n",
      "11 青岛s 在啤酒柜中\n",
      "11 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "10 青岛s 在啤酒柜中\n",
      "\n",
      "10 青岛s 在啤酒柜中\n",
      "10 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "9 青岛s 在啤酒柜中\n",
      "\n",
      "9 青岛s 在啤酒柜中\n",
      "9 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "8 青岛s 在啤酒柜中\n",
      "\n",
      "8 青岛s 在啤酒柜中\n",
      "8 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "7 青岛s 在啤酒柜中\n",
      "\n",
      "7 青岛s 在啤酒柜中\n",
      "7 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "6 青岛s 在啤酒柜中\n",
      "\n",
      "6 青岛s 在啤酒柜中\n",
      "6 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "5 青岛s 在啤酒柜中\n",
      "\n",
      "5 青岛s 在啤酒柜中\n",
      "5 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "4 青岛s 在啤酒柜中\n",
      "\n",
      "4 青岛s 在啤酒柜中\n",
      "4 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "3 青岛s 在啤酒柜中\n",
      "\n",
      "3 青岛s 在啤酒柜中\n",
      "3 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "2 青岛s 在啤酒柜中\n",
      "\n",
      "2 青岛s 在啤酒柜中\n",
      "2 瓶 青岛s\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "1 青岛 在啤酒柜中\n",
      "\n",
      "1 青岛 在啤酒柜中\n",
      "1 瓶 青岛\n",
      "一次可以拿一瓶~\n",
      "Pass it around~\n",
      "啤酒售罄咯~\n",
      "\n"
     ]
    }
   ],
   "source": [
    "word = \"青岛s\"\n",
    "# 循环，for 一般和range使用，range决定了循环的次数\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"在啤酒柜中\")\n",
    "    print(beer_num,\"瓶\",word)\n",
    "    print(\"一次可以拿一瓶~\")\n",
    "    print(\"Pass it around~\")\n",
    "    \n",
    "    if beer_num == 1:\n",
    "        print(\"啤酒售罄咯~\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"青岛\"\n",
    "        print(new_num,word,\"在啤酒柜中\")\n",
    "    print()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "82a7efc9",
   "metadata": {},
   "source": [
    "# 2.用户输入(input)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "c79a4865",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入您的账号: LinWenxuan\n"
     ]
    }
   ],
   "source": [
    "# 变量赋值（我们决定变量的数据结构和内容）\n",
    "username = input(\"请输入您的账号: \")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f1251442",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LinWenxuan\n",
      "<class 'str'>\n"
     ]
    }
   ],
   "source": [
    "print(username)\n",
    "print(type(username))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e2d3f4ff",
   "metadata": {},
   "source": [
    "# 2.1 input实践：用户登录"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "2b10d02e",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyboardInterrupt",
     "evalue": "Interrupted by user",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-13-29e9f09b36a7>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[1;31m# 2.用户登录\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m \u001b[0musername\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"请输入您的账号\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      7\u001b[0m \u001b[1;32mif\u001b[0m \u001b[0musername_data\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0musername\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      8\u001b[0m     \u001b[1;31m#账号存在\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mE:\\Anaconda\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[1;34m(self, prompt)\u001b[0m\n\u001b[0;32m    858\u001b[0m                 \u001b[1;34m\"raw_input was called, but this frontend does not support input requests.\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    859\u001b[0m             )\n\u001b[1;32m--> 860\u001b[1;33m         return self._input_request(str(prompt),\n\u001b[0m\u001b[0;32m    861\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    862\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mE:\\Anaconda\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[1;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[0;32m    902\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    903\u001b[0m                 \u001b[1;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 904\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Interrupted by user\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    905\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    906\u001b[0m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwarning\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Invalid Message:\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexc_info\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: Interrupted by user"
     ]
    }
   ],
   "source": [
    "# 首先：数据库信息有账号和密码\n",
    "username_data = \"LinWenxuan\"\n",
    "password_data = \"123456\"\n",
    "\n",
    "# 2.用户登录\n",
    "username = input(\"请输入您的账号\")\n",
    "if username_data == username:\n",
    "    #账号存在\n",
    "    password = input(\"请输入您的密码:\")\n",
    "    if password_data == password:\n",
    "        #密码正确\n",
    "        print(\"欢迎\",username,\"使用\")\n",
    "    else:\n",
    "        #密码错误\n",
    "        print(\"您输入的密码不正确！请重新输入或请求帮助\")\n",
    "else:\n",
    "    print(\"您输入的账号不存在，请重新输入\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8389aaed",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyboardInterrupt",
     "evalue": "Interrupted by user",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-14-ea6c3a1fb2bb>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mpassword_data\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"123456\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;32mwhile\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m     \u001b[0musername\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"请输入您的账号:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m     \u001b[0mpassword\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"请输入您的密码:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0musername_data\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0musername\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mpassword_data\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mpassword\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mE:\\Anaconda\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[1;34m(self, prompt)\u001b[0m\n\u001b[0;32m    858\u001b[0m                 \u001b[1;34m\"raw_input was called, but this frontend does not support input requests.\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    859\u001b[0m             )\n\u001b[1;32m--> 860\u001b[1;33m         return self._input_request(str(prompt),\n\u001b[0m\u001b[0;32m    861\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    862\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mE:\\Anaconda\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[1;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[0;32m    902\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    903\u001b[0m                 \u001b[1;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 904\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Interrupted by user\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    905\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    906\u001b[0m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwarning\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Invalid Message:\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexc_info\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: Interrupted by user"
     ]
    }
   ],
   "source": [
    "username_data = \"LinWenxuan\"\n",
    "password_data = \"123456\"\n",
    "while True:\n",
    "    username = input(\"请输入您的账号:\")\n",
    "    password = input(\"请输入您的密码:\")\n",
    "    if username_data == username and password_data == password:\n",
    "        print(\"欢迎\",username,\"使用\")\n",
    "    else:\n",
    "        print(\"账号不存在或密码错误\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "ffb8f3aa",
   "metadata": {},
   "outputs": [
    {
     "ename": "KeyboardInterrupt",
     "evalue": "Interrupted by user",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-17-b0b28fd4c1fb>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[0mpassword_data\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m\"123456\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[1;32mwhile\u001b[0m \u001b[1;32mTrue\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m     \u001b[0musername\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"请输入您的账号:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m      5\u001b[0m     \u001b[0mpassword\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0minput\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"请输入您的密码:\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      6\u001b[0m     \u001b[1;32mif\u001b[0m \u001b[0musername_data\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0musername\u001b[0m \u001b[1;32mand\u001b[0m \u001b[0mpassword_data\u001b[0m \u001b[1;33m==\u001b[0m \u001b[0mpassword\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mE:\\Anaconda\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36mraw_input\u001b[1;34m(self, prompt)\u001b[0m\n\u001b[0;32m    858\u001b[0m                 \u001b[1;34m\"raw_input was called, but this frontend does not support input requests.\"\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    859\u001b[0m             )\n\u001b[1;32m--> 860\u001b[1;33m         return self._input_request(str(prompt),\n\u001b[0m\u001b[0;32m    861\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_ident\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    862\u001b[0m             \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_parent_header\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;32mE:\\Anaconda\\lib\\site-packages\\ipykernel\\kernelbase.py\u001b[0m in \u001b[0;36m_input_request\u001b[1;34m(self, prompt, ident, parent, password)\u001b[0m\n\u001b[0;32m    902\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    903\u001b[0m                 \u001b[1;31m# re-raise KeyboardInterrupt, to truncate traceback\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 904\u001b[1;33m                 \u001b[1;32mraise\u001b[0m \u001b[0mKeyboardInterrupt\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Interrupted by user\"\u001b[0m\u001b[1;33m)\u001b[0m \u001b[1;32mfrom\u001b[0m \u001b[1;32mNone\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    905\u001b[0m             \u001b[1;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    906\u001b[0m                 \u001b[0mself\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwarning\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"Invalid Message:\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mexc_info\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;32mTrue\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mKeyboardInterrupt\u001b[0m: Interrupted by user"
     ]
    }
   ],
   "source": [
    "username_data = \"LinWenxuan\"\n",
    "password_data = \"123456\"\n",
    "while True:\n",
    "    username = input(\"请输入您的账号:\")\n",
    "    password = input(\"请输入您的密码:\")\n",
    "    if username_data == username and password_data == password:\n",
    "        print(\"欢迎\",username,\"使用\")\n",
    "    elif username_data == username and password_data != password:\n",
    "        print(\"您输入的密码错误，请重新输入或寻求帮助\")\n",
    "    elif username_data != username and password_data == password:\n",
    "        print(\"账户不存在\")\n",
    "    else:\n",
    "        print(\"账号不存在或密码错误\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "68bbf4ad",
   "metadata": {},
   "source": [
    "# 2.2 占位符和字符串格式化"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b20e6ac1",
   "metadata": {},
   "source": [
    "## 1.%s占位符打印用户信息实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "e0a8299d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:LinWenxuan\n",
      "age:19\n",
      "job:Student\n",
      "salary:0\n",
      "-------INFO OF LinWenxuan -------\n",
      "Name:LinWenxuan\n",
      "Age:19\n",
      "Job:Student\n",
      "Salary:0\n",
      "\n"
     ]
    }
   ],
   "source": [
    "name = input(\"name:\")\n",
    "age = input(\"age:\")\n",
    "job = input(\"job:\")\n",
    "salary = input(\"salary:\")\n",
    "\n",
    "info = '''-------INFO OF %s -------\n",
    "Name:%s\n",
    "Age:%s\n",
    "Job:%s\n",
    "Salary:%s\n",
    "'''% (name,name,age,job,salary)\n",
    "\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fdcf2e45",
   "metadata": {},
   "source": [
    "## 2..format()打印用户信息实践"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "6b068261",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-------INFO OF LinWenxuan -------\n",
      "Name:LinWenxuan\n",
      "Age:19\n",
      "Job:Student\n",
      "Salary:0\n",
      "\n"
     ]
    }
   ],
   "source": [
    "info2 =  '''-------INFO OF {_name} -------\n",
    "Name:{_name}\n",
    "Age:{_age}\n",
    "Job:{_job}\n",
    "Salary:{_salary}\n",
    "'''.format(_name=name,\n",
    "           _age=age,\n",
    "           _job=job,\n",
    "           _salary=salary)\n",
    "print(info2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a30967f5",
   "metadata": {},
   "source": [
    "# 2.while循环(while True)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "9d0f10c6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "wryyyyyyy 1\n",
      "wryyyyyyy 2\n",
      "wryyyyyyy 3\n",
      "wryyyyyyy 4\n",
      "wryyyyyyy 5\n",
      "wryyyyyyy 6\n",
      "wryyyyyyy 7\n",
      "wryyyyyyy 8\n",
      "wryyyyyyy 9\n",
      "wryyyyyyy 10\n"
     ]
    }
   ],
   "source": [
    "count = 0\n",
    "while True:\n",
    "    count = count + 1\n",
    "    print(\"wryyyyyyy\",count)\n",
    "    if count == 10:\n",
    "        break\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3f59fdc2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入您的账号:awdawdawd\n",
      "请输入您的密码:awdawdawd\n",
      "您输入的账号不存在或密码不正确~，请重新输入~,您还有 2 次输入当机会，否则5秒钟后再来尝试~~~\n",
      "请输入您的账号:awdawdaw\n",
      "请输入您的密码:awdawdaw\n",
      "您输入的账号不存在或密码不正确~，请重新输入~,您还有 1 次输入当机会，否则5秒钟后再来尝试~~~\n",
      "请输入您的账号:awdawdawd\n",
      "请输入您的密码:awdawd\n",
      "请等待5秒钟\n",
      "请输入您的账号:LinWenxuan\n",
      "请输入您的密码:123456\n",
      "欢迎 LinWenxuan 使用\n"
     ]
    }
   ],
   "source": [
    "import time\n",
    "username_data = \"LinWenxuan\"\n",
    "password_data = \"123456\"\n",
    "count = 3\n",
    "while True:\n",
    "    count -= 1 #等价于  count = count -1\n",
    "    username = input(\"请输入您的账号:\")\n",
    "    password = input(\"请输入您的密码:\")\n",
    "    if username_data == username and password_data == password:\n",
    "        print(\"欢迎\",username,\"使用\")\n",
    "    elif count == 0:\n",
    "        print(\"请等待5秒钟\")\n",
    "        time.sleep(5)\n",
    "        count = 3\n",
    "    else:\n",
    "        print(\"您输入的账号不存在或密码不正确~，请重新输入~,您还有\",count,\"次输入当机会，否则5秒钟后再来尝试~~~\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "eaee4890",
   "metadata": {},
   "source": [
    "# 3.列表引入"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "48741197",
   "metadata": {},
   "source": [
    ">1.什么是列表   \n",
    ">2.列表的形式：[value1,value2,...]   \n",
    ">3.列表也是\"序列\"数据类型   \n",
    ">>1.序列是有顺序的（即可以用索引 index 取值）   \n",
    ">>2.序列可以切片 ,切片完的结果仍是一个列表   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "2428ad14",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1, 4, 9, 16, 25]\n",
      "<class 'list'>\n"
     ]
    }
   ],
   "source": [
    "squares = [1, 4, 9, 16, 25]\n",
    "print(squares)\n",
    "print(type(squares))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "e765bf38",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Alex'"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 思考： 用户账号数据不止一个，那么想存储怎么办？\n",
    "username_database = \"Alex,zhichao,xiaoming,Jack\"\n",
    "username_database[:4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "a63bbc3c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Alex'"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "username_database_list = [\"Alex\",\"zhichao\",\"xiaoming\",\"Jack\"]\n",
    "username_database_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "5ae182b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'zhichao'"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "username_database_list[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "2e81bf00",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Alex', 'zhichao']"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "username_database_list[0:2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "452422bd",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
